package com.dshore.messagecenter.controller.overview;


import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.dshore.messagecenter.controller.basedata.BaseController;
import com.dshore.messagecenter.model.system.McColumnInfo;
import com.dshore.messagecenter.model.system.Menu;
import com.dshore.messagecenter.model.system.ResponseResult;
import com.dshore.messagecenter.model.system.User;
import com.dshore.messagecenter.service.overview.IndexService;


/**
 * 主页控制类
 * @author  panyi
 * @Date 2018/7/19
 * @version 1.0.0
 */
@Controller
@RequestMapping("/index")
public class IndexController extends BaseController{
	@Autowired
	private IndexService indexService;
	
	
	
	private ArrayList<Menu>arrayList;
	
	//返回到主页
	@RequestMapping("/toIndex")
	public ModelAndView IntoIndex() {
		ModelAndView mv=new ModelAndView("index");
		mv.setViewName("overview/index");
		return mv;
	}	
	
	@RequestMapping("/overView")
	public ModelAndView IntoMainIndex() {
		ModelAndView mv=new ModelAndView("overview/overView");
		return mv;
	}
	
	@RequestMapping("/toDemo")
	public ModelAndView IntoDemo() {
		ModelAndView mv=new ModelAndView("demo");
		return mv;
	}
	
	@RequestMapping("/getMenu")
	@ResponseBody
	public List<List<McColumnInfo>>getMenu() {
		//查看左侧边栏的一级菜单
		List<McColumnInfo> list=indexService.queryFirstColumnList();
		
		//查看二级标题主题队列等
		List<McColumnInfo>list1=indexService.querySecondColumnList1();
		List<McColumnInfo>list2=indexService.querySecondColumnList2();
		List<McColumnInfo>list3=indexService.querySecondColumnList3();
		List<McColumnInfo>list4=indexService.querySecondColumnList4();
		List<McColumnInfo>list5=indexService.querySecondColumnList5();
		List<McColumnInfo>list6=indexService.querySecondColumnList6();
		List<List<McColumnInfo>> li=new ArrayList<List<McColumnInfo>>();
		li.add(list);
		li.add(list1);
		li.add(list2);
		li.add(list3);
		li.add(list4);
		li.add(list5);
		li.add(list6);
		return li;
	}
	
	@RequestMapping("/getPid")
	@ResponseBody
	public List<Integer> getPid(){
		List<Integer> pidList=indexService.queryAllPid();
		return pidList;
	}
	
	@RequestMapping("/getMenu1")
	@ResponseBody
	public List<McColumnInfo> getMenu1(Integer pid) {
		List<McColumnInfo> li=indexService.getMenuByPid(pid);
		return li;
	}
	
	/**
	 * 获取应用数
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/getAppAmount")
	@ResponseBody	
	public List<Object> getAppAmount(){
		List<Object> list=indexService.getAppAmount();
		return list;
	}
	
	/**
	 * 获取主题数
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/getToppicAmount")
	@ResponseBody	
	public List<Object> getToppicAmount(){
		List<Object> list=indexService.getToppicAmount();
		return list;
	}
	
	/**
	 * 获取消息流量
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/getMessageAmount")
	@ResponseBody	
	public List<Object> getMessageAmount(){
		List<Object> list=indexService.getMessageAmount();
		return list;
	}
	
	/**
	 * 获取消息发送平均延迟
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/getAvgDelay")
	@ResponseBody	
	public List<Object> getAvgDelay(){
		List<Object> list=indexService.getAvgDelay();
		return list;
	}
	
	
	/**
	 * 获取实时消息流量数据，第一个图表
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/getMessageByNowTime")
	@ResponseBody
	public List<List<String>> getMessageByNowTime() {
		List<List<String>> li=indexService.getMessageByNowTime();
		return li;
	}
	
	/**
	 * 获取实时延迟数据，第二个图表
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/getDelayByNowTime")
	@ResponseBody
	public List<List<String>> getDelayByNowTime() {
		List<List<String>> li=indexService.getDelayByNowTime();
		return li;
	}
	
	/**
	 * 根据毫秒数获得当前秒的实时内存数据，第三个图表
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/getDataByDate")
	@ResponseBody
	public List<List<String>> getDataByDate() {
		List<List<String>> li=indexService.getDataByDate();
		return li;
	}
	
	/**
	 * 根据毫秒数获得当前秒的实时磁盘数据，第四个个图表
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/getcipan")
	@ResponseBody
	public List<List<String>> getcipan() {
		List<List<String>> li=indexService.getcipan();
		return li;
	}

	@RequestMapping("/isLogin")
	@ResponseBody
	public ResponseResult<Void> isLogin(HttpServletRequest request){
		ResponseResult<Void>responseResult=new ResponseResult<>(200);
			return responseResult;
		
	}
	
	/**
	 * 获取用户
	 * @return
	 */
	@RequestMapping("/getUser")
	@ResponseBody	
	public List<User> getUser(){
		List<User> list=indexService.getUser();
		return list;
	}
	
	
}
